home *** CD-ROM | disk | FTP | other *** search
/ PC Users 8 / Cd Pc Users extra 8.iso / prog / inst / firstimp / vcimpres.z / Chdraw.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-11-07  |  10.2 KB  |  292 lines

  1. VERSION 5.00
  2. Object = "{335C3C4F-E3F2-11D0-87E8-00A0C903B29D}#5.0#0"; "VCFI5.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   6315
  6.    ClientLeft      =   3495
  7.    ClientTop       =   2190
  8.    ClientWidth     =   9015
  9.    LinkTopic       =   "Form1"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   6315
  12.    ScaleWidth      =   9015
  13.    Begin VB.Frame Frame1 
  14.       Caption         =   " Text Metrics "
  15.       Height          =   795
  16.       Index           =   3
  17.       Left            =   5640
  18.       TabIndex        =   1
  19.       Top             =   3420
  20.       Width           =   2655
  21.    End
  22.    Begin VB.Frame Frame1 
  23.       Caption         =   " Chart Formatting "
  24.       Height          =   795
  25.       Index           =   1
  26.       Left            =   5640
  27.       TabIndex        =   6
  28.       Top             =   4320
  29.       Width           =   2655
  30.    End
  31.    Begin VB.Frame Frame1 
  32.       Caption         =   " Draw To: "
  33.       Height          =   795
  34.       Index           =   0
  35.       Left            =   5640
  36.       TabIndex        =   3
  37.       Top             =   5220
  38.       Width           =   2655
  39.       Begin VB.CommandButton cmdPicture 
  40.          Caption         =   "Picture"
  41.          Height          =   375
  42.          Left            =   180
  43.          MousePointer    =   1  'Arrow
  44.          TabIndex        =   5
  45.          Top             =   300
  46.          Width           =   915
  47.       End
  48.       Begin VB.CommandButton cmdPrinter 
  49.          Caption         =   "Printer"
  50.          Height          =   375
  51.          Left            =   1200
  52.          TabIndex        =   4
  53.          Top             =   300
  54.          Width           =   915
  55.       End
  56.    End
  57.    Begin VB.PictureBox Picture1 
  58.       Appearance      =   0  'Flat
  59.       AutoRedraw      =   -1  'True
  60.       BackColor       =   &H80000005&
  61.       ClipControls    =   0   'False
  62.       ForeColor       =   &H80000008&
  63.       Height          =   3195
  64.       Left            =   5580
  65.       ScaleHeight     =   3165
  66.       ScaleWidth      =   3225
  67.       TabIndex        =   2
  68.       Top             =   60
  69.       Width           =   3255
  70.    End
  71.    Begin VtChartLib.VtChart VtChart1 
  72.       Height          =   6195
  73.       Left            =   60
  74.       TabIndex        =   0
  75.       Top             =   0
  76.       Width           =   5355
  77.       _ExtentX        =   9446
  78.       _ExtentY        =   10927
  79.       _0              =   $"Chdraw.frx":0000
  80.       _1              =   $"Chdraw.frx":0405
  81.       _2              =   $"Chdraw.frx":080A
  82.       _3              =   $"Chdraw.frx":0C0F
  83.       _4              =   $"Chdraw.frx":1014
  84.       _5              =   $"Chdraw.frx":1419
  85.       _6              =   $"Chdraw.frx":181E
  86.       _7              =   $"Chdraw.frx":1C23
  87.       _8              =   $"Chdraw.frx":2028
  88.       _9              =   $"Chdraw.frx":242D
  89.       _10             =   $"Chdraw.frx":2832
  90.       _11             =   $"Chdraw.frx":2C37
  91.       _12             =   $"Chdraw.frx":303C
  92.       _13             =   $"Chdraw.frx":3441
  93.       _14             =   $"Chdraw.frx":3846
  94.       _count          =   15
  95.       _ver            =   1
  96.    End
  97. Attribute VB_Name = "Form1"
  98. Attribute VB_GlobalNameSpace = False
  99. Attribute VB_Creatable = False
  100. Attribute VB_PredeclaredId = True
  101. Attribute VB_Exposed = False
  102. Private Sub chkLayout_Click(Value As Integer)
  103.     ' Scaled is only used if Layout is False
  104.     chkStretch.Enabled = Not (chkLayout.Value)
  105. End Sub
  106. Private Sub cmdPicture_Click()
  107.    On Error GoTo DrawPictureError
  108.    Dim top%, left%, bottom%, right%
  109.    ' Set the destination to the entire picture box.
  110.    ' Convert from twips (default) to pixels with the
  111.    ' Screen.TwipsPerPixelX property. Note that you can
  112.    ' suffer roundoff error here so you may want to pad
  113.    ' the width and height.
  114.    top = Picture1.ScaleTop / Screen.TwipsPerPixelY
  115.    left = Picture1.ScaleLeft / Screen.TwipsPerPixelX
  116.    bottom = Picture1.ScaleHeight / Screen.TwipsPerPixelY + 2
  117.    right = Picture1.ScaleWidth / Screen.TwipsPerPixelX + 2
  118.    ' Clear out the old image
  119.    Picture1.Cls
  120.    ' Use the check boxes for args so we can readily see how
  121.    ' each possiblity affects the image.
  122.    VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
  123.       bottom, right, True, True
  124.    'VtChart1.Draw
  125.    Exit Sub
  126. DrawPictureError:
  127.    MsgBox Error
  128. End Sub
  129. Private Sub Command1_Click()
  130.    On Error GoTo DrawPrinterError
  131.    Dim top%, left%, bottom%, right%
  132.    Dim titleWidth&, titleHeight&
  133.    With Printer
  134.       ' Set the font and position a title on the page.
  135.       ' The chart already has a title -
  136.       ' this title is text drawn directly on the  object.
  137.       .FontSize = 48
  138.       .FontName = "Times New Roman"
  139.       .FontUnderline = True
  140.       titleWidth = .TextWidth("VtChDraw Example")
  141.       titleHeight = .TextHeight("VtChDraw Example")
  142.       
  143.       ' Center the text and move it down off the top margin
  144.       .CurrentX = .ScaleLeft + (.ScaleWidth - titleWidth) / 2
  145.       .CurrentY = 0.3 * titleHeight
  146.       ' Draw the text on the hDC
  147.       Printer.Print "VtChDraw Example"
  148.       
  149.       ' Bounding rect for the chart. Place below Title and conert from twips to pixels.
  150.       top = (.ScaleTop + titleHeight) / .TwipsPerPixelY
  151.       left = .ScaleLeft / .TwipsPerPixelX
  152.       bottom = .ScaleHeight / .TwipsPerPixelY
  153.       right = .ScaleWidth / .TwipsPerPixelX
  154.       
  155.       ' Draw the chart on the  hDC using the option check boxes
  156.       ' as arguments
  157.       VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
  158.          bottom, right, chkLayout.Value, chkStretch.Value
  159.       
  160.       ' Use these to adjust the line drawings
  161.       '.DrawMode =
  162.       '.DrawStyle =
  163.       '.DrawWidth =
  164.       '.ForeColor =
  165.       
  166.       ' Draw a bounding box
  167.       Printer.Line (.ScaleLeft, .ScaleTop)-(.ScaleWidth, .ScaleTop)
  168.       Printer.Line (.ScaleWidth - 5, .ScaleTop)-(.ScaleWidth - 5, .ScaleHeight)
  169.       Printer.Line (.ScaleWidth - 5, .ScaleHeight - 5)-(.ScaleLeft, .ScaleHeight - 5)
  170.       Printer.Line (.ScaleLeft, .ScaleHeight - 5)-(.ScaleLeft, .ScaleTop)
  171.       
  172.       ' Feed a page and then flush it through the
  173.       .NewPage
  174.       .EndDoc
  175.    End With
  176.    Exit Sub
  177. DrawPrinterError:
  178.    MsgBox Error
  179. End Sub
  180. Private Sub Command2_Click()
  181.    On Error GoTo DrawPictureError
  182.    Dim top%, left%, bottom%, right%
  183.    ' Set the destination to the entire picture box.
  184.    ' Convert from twips (default) to pixels with the
  185.    ' Screen.TwipsPerPixelX property. Note that you can
  186.    ' suffer roundoff error here so you may want to pad
  187.    ' the width and height.
  188.    top = Picture1.ScaleTop / Screen.TwipsPerPixelY
  189.    left = Picture1.ScaleLeft / Screen.TwipsPerPixelX
  190.    bottom = Picture1.ScaleHeight / Screen.TwipsPerPixelY + 2
  191.    right = Picture1.ScaleWidth / Screen.TwipsPerPixelX + 2
  192.    ' Clear out the old image
  193.    Picture1.Cls
  194.    ' Use the check boxes for args so we can readily see how
  195.    ' each possiblity affects the image.
  196.    VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
  197.       bottom, right, chkLayout.Value, chkStretch.Value
  198.       
  199.    Exit Sub
  200. DrawPictureError:
  201.    MsgBox Error
  202. End Sub
  203. Private Sub cmdPrinter_Click()
  204.    On Error GoTo DrawPrinterError
  205.    Dim top%, left%, bottom%, right%
  206.    Dim titleWidth&, titleHeight&
  207.    With Printer
  208.       ' Set the font and position a title on the page.
  209.       ' The chart already has a title -
  210.       ' this title is text drawn directly on the  object.
  211.       .FontSize = 48
  212.       .FontName = "Times New Roman"
  213.       .FontUnderline = True
  214.       titleWidth = .TextWidth("VtChDraw Example")
  215.       titleHeight = .TextHeight("VtChDraw Example")
  216.       
  217.       ' Center the text and move it down off the top margin
  218.       .CurrentX = .ScaleLeft + (.ScaleWidth - titleWidth) / 2
  219.       .CurrentY = 0.3 * titleHeight
  220.       ' Draw the text on the hDC
  221.       Printer.Print "VtChDraw Example"
  222.       
  223.       ' Bounding rect for the chart. Place below Title and conert from twips to pixels.
  224.       top = (.ScaleTop + titleHeight) / .TwipsPerPixelY
  225.       left = .ScaleLeft / .TwipsPerPixelX
  226.       bottom = .ScaleHeight / .TwipsPerPixelY
  227.       right = .ScaleWidth / .TwipsPerPixelX
  228.       
  229.       ' Draw the chart on the  hDC using the option check boxes
  230.       ' as arguments
  231.       VtChart1.Draw Printer.hDC, VtDcTypeDisplay, top, left, _
  232.          bottom, right, False, True
  233.       
  234.       ' Use these to adjust the line drawings
  235.       '.DrawMode =
  236.       '.DrawStyle =
  237.       '.DrawWidth =
  238.       '.ForeColor =
  239.       
  240.       ' Draw a bounding box
  241.       Printer.Line (.ScaleLeft, .ScaleTop)-(.ScaleWidth, .ScaleTop)
  242.       Printer.Line (.ScaleWidth - 5, .ScaleTop)-(.ScaleWidth - 5, .ScaleHeight)
  243.       Printer.Line (.ScaleWidth - 5, .ScaleHeight - 5)-(.ScaleLeft, .ScaleHeight - 5)
  244.       Printer.Line (.ScaleLeft, .ScaleHeight - 5)-(.ScaleLeft, .ScaleTop)
  245.       
  246.       ' Feed a page and then flush it through the
  247.       .NewPage
  248.       .EndDoc
  249.    End With
  250.    Exit Sub
  251. DrawPrinterError:
  252.    MsgBox Error
  253. End Sub
  254. Private Sub Form_Load()
  255.    ' Put the form in the top left corner
  256.    Form1.left = 0
  257.    Form1.top = 0
  258.    'pnlControls.top = 60
  259.    VtChart1.top = 120
  260. End Sub
  261. Private Sub Form1_Click()
  262. End Sub
  263. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  264.    End
  265. End Sub
  266. Private Sub Form_Resize()
  267.    VtChart1.Repaint = False
  268.    If ScaleHeight > 7200 Then
  269.       'pnlControls.Height = ScaleHeight - 135
  270.       VtChart1.Height = ScaleHeight - 255
  271.    End If
  272.    If ScaleWidth > 4000 Then
  273.       'pnlControls.left = ScaleWidth - pnlControls.Width - 60
  274.       'VtChart1.Width = pnlControls.left - 235
  275.    End If
  276.    VtChart1.Repaint = True
  277. End Sub
  278. Private Sub optTextMetrics_Click(Index As Integer, Value As Integer)
  279. '' Screen and printer text metrics are different. If you
  280. '' draw to the screen, you will want to use virtual metrics
  281. '' (defined by the TrueType font). Otherwise use the device
  282. '' type which is optimized for your output device.
  283.    If Value Then
  284.       Select Case Index
  285.          Case 0
  286.             VtChart1.TextLengthType = VtTextLengthTypeVirtual
  287.          Case 1
  288.             VtChart1.TextLengthType = VtTextLengthTypeDevice
  289.       End Select
  290.    End If
  291. End Sub
  292.